package de.karlNet.sambamanager.ldapController.commands.macros;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Controller;

import de.karlNet.sambamanager.ldapController.commands.AddGroupMembersAndMemberOf;
import de.karlNet.sambamanager.ldapController.commands.BaseCommand;
import de.karlNet.sambamanager.ldapController.commands.CreateGroup;
import de.karlNet.sambamanager.ldapModel.dto.LdapGroupCreationDTO;

@Controller
@Scope(value="session", proxyMode=ScopedProxyMode.TARGET_CLASS)
public class CreateGroupMacro extends BaseCommand {
	@Autowired
	private CreateGroup createGroup;
	@Autowired
	private AddGroupMembersAndMemberOf addGroupMemberOf;
	
	

	public void createGroup(LdapGroupCreationDTO ldapGroupCreationDTO) {
		this.createGroup.createGroupItself(ldapGroupCreationDTO.getLdapGroup());
		this.addGroupMemberOf.addUserToGroupItself(ldapGroupCreationDTO);
		this.resetTrees();
	}
}
